<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 200px;
            background-color: brown;
        }
    </style>
</head>

<body>
    <div id="dv"></div>
    <input type="button" value="点击变宽" id="btn" />
    <script>
        function my$(id) {
            return document.getElementById(id);
        }

        my$("btn").onclick = function () {
            var width = 300;
            var timeId = setInterval(function () {
                width += 50;
                if (width == 800) {
                    clearInterval(timeId);
                }
                my$("dv").style.width = width+"px";
            }, 200)
        }

    </script>
</body>

</html>